// 文章相关的所有请求
import { ArticleInter, ArticleQueryParamsInter } from '@/typings/interface'
import { request } from '@/utils'

// 获取频道列表
export const getChannelAPI  = () => {
  return request({
    url: '/channels',
    method: 'GET',
  })
}

// 新增文章表单
export const createArticleAPI = (data: ArticleInter) => {
  return request({
    url: '/mp/articles?draft=false',
    method: 'POST',
    data
  })
}

// 获取文章列表
export const getArticleListAPI = (params: ArticleQueryParamsInter) => {
  return request({
    url: '/mp/articles',
    method: 'GET',
    params
  })
}

// 删除文章
export const delArticleAPI = (id: string) => {
  return request({
    url: `/mp/articles/${id}`,
    method: 'DELETE',
  })
}

// 获取文章详情
export const getArticleByIdAPI = (id: string) => {
  return request({
    url: `/mp/articles/${id}`,
    method: 'GET'
  })
}


// 编辑文章表单
export const updateArticleAPI = (data: ArticleInter) => {
  return request({
    url: `/mp/articles/${data.id}?draft=false`,
    method: 'PUT',
    data
  })
}